package application.common.util;


import com.jfinal.kit.StrKit;

import application.mvc.sys.index.IndexController;
import net.sf.json.JSONObject;

public class HandleMessgeUtil {
	
	private static IndexController indexController;


	public static void doHandle(String message) {
		
		if(StrKit.isBlank(message) || StrKit.equals("close", message)) {	
			return;
		}
		try {
 			JSONObject object = JSONObject.fromObject(message);
			if(object!=null && !StrKit.isBlank(object.getString("code"))) {
				String code=object.getString("code");
				//年内案件统计
				if(StrKit.equals(code,"archives")) {
					if(indexController!=null) {
						indexController.message(message);
					}
				}
				//预警信息
				else if(StrKit.equals(code,"warning")) {
					if(indexController!=null) {
						indexController.message(message);
					}
				}
				//补充档案信息
				else if(StrKit.equals(code,"archive")) {
					if(indexController!=null) {
						indexController.message(message);
					}
				}
				//配置信息
				else if(StrKit.equals(code,"config")) {
					
				}
				//用户变
				else if(StrKit.equals(code,"user")) {
				}				
			}
		}catch (Exception e) {
		}
	}

	public static IndexController getIndexController() {
		return indexController;
	}

	public static void setIndexController(IndexController indexController) {
		HandleMessgeUtil.indexController = indexController;
	}
}
